# 新增元素
stu_score = {
    "王力宏": 77,
    "周杰伦": 88,
    "林俊杰": 99
}
stu_score["张学友"] = 66
print(f"字典新增元素后为{stu_score}")

# 更新元素
stu_score["周杰伦"] = 86
print(f"字典更新元素后为{stu_score}")

# 删除元素
score = stu_score.pop("林俊杰")
print(f"删除元素后为：{stu_score}，林俊杰的分数是{score}")


# 清空字典
stu_score.clear()
print(f"清空字典后：{stu_score}")

# 获取全部的Key
stu_score = {
    "王力宏": 77,
    "周杰伦": 88,
    "林俊杰": 99
}
keys = stu_score.keys()
print(f"字典的全部key是:{keys}")

# 遍历字典
# 方法一：通过获取全部的key来完成遍历
for key in keys:
    print(f"字典的key是：{key}")
    print(f"字典的Value是：{stu_score[key]}")

# 方法二：直接对字典进行for循环，每次都是直接得到key
for key in stu_score:
    print(f"2字典的key是：{key}")
    print(f"2字典的Value是：{stu_score[key]}")

my_dict4 = {
    "王力宏": {
        "语文": 77,
        "数学": 66,
        "英语": 33
    },
    "周杰伦": {
        "语文": 88,
        "数学": 86,
        "英语": 55}
    ,
    "林俊杰": {
        "语文": 99,
        "数学": 96,
        "英语": 66
    }
}
keys2 = my_dict4.keys()
for key in keys2:
    for key in my_dict4:
        print(f"字典的key是：{key}")
        print(f"字典的Value是：{stu_score[key]}")